package com.px.chapter_Dec_1.thread;

public class Test2 {

    public static void main(String[] args)  {
        TTT seall=new TTT();
        Thread thread1=new Thread(seall,"1号");
        Thread thread2=new Thread(seall,"2号");
        Thread thread3=new Thread(new Runnable() {
            @Override
            public void run() {
                while (true){
                System.out.println(thread1.getState()+"\t"+thread2.getState());
                    try {
                        Thread.sleep(9);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        });
    thread3.setDaemon(true);
    thread1.start();thread2.start();thread3.start();


    }}

    class TTT implements Runnable{
        private int kkk=10;
        @Override
        public void run() {
            int c=1;
            while (kkk>0){
                System.out.println(Thread.currentThread().getName()+"出售"+c);
                c++;
                kkk--;
                try {
                    Thread.sleep(10);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }}

